<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="renderer" content="webkit">
    <link rel="stylesheet" href="/mdui/css/mdui.min.css">
    <script defer src="/mdui/js/mdui.min.js"></script>
    <script src="/js/axios.min.js"></script>
    <script src="/js/qs.min.js"></script>
    <script src="/js/common.js"></script>
    <script src="/js/vue.js"></script>
</head>
<body class="mdui-theme-primary-indigo mdui-theme-accent-pink">


<div class="mdui-container-fluid" id="app">

    <h1 class="mdui-text-color-theme">发起审批</h1>

    <!-- 固定标签 -->
    <div class="mdui-textfield">
        <i class="mdui-icon material-icons">account_circle</i>
        <label class="mdui-textfield-label">提交人</label>
        <input class=" mdui-textfield-input" type="text" v-model="task.useriinfo.name" readonly/>
    </div>
    <!-- 固定标签 -->
    <div class="mdui-textfield">
        <i class="mdui-icon material-icons">account_circle</i>
        <label class="mdui-textfield-label">提交时间</label>
        <input class=" mdui-textfield-input" type="text" v-model="task.createTime" readonly/>
    </div>
    <!-- 固定标签 -->
    <div class="mdui-textfield">
        <i class="mdui-icon material-icons">account_circle</i>
        <label class="mdui-textfield-label">标题</label>
        <input class=" mdui-textfield-input" type="text" v-model="task.title" readonly/>
    </div>
    <!-- 固定标签 -->
    <div class="mdui-textfield">
        <i class="mdui-icon material-icons">account_circle</i>
        <label class="mdui-textfield-label">内容</label>
        <textarea class="mdui-textfield-input" rows="4" placeholder="请输入内容" v-model="task.content"
                  readonly></textarea>

    </div>
    <div class="mdui-textfield">
        <i class="mdui-icon material-icons">account_circle</i>
        <label class="mdui-textfield-label">回复内容</label>
        <textarea class="mdui-textfield-input" rows="4" placeholder="请输入内容" v-model="task.reply"
        ></textarea>

    </div>


    <div style="text-align: center">
        <button v-if="show" @click="dotask(true)" class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-green-800">
            通过
        </button>
        <button v-if="show" @click="dotask(false)" class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-green-800">
            拒绝
        </button>
        <a href="javascript:history.back()" class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-green-800">返回</a>
    </div>

</div>

<script>
    let params = new URLSearchParams(location.search);
    let taskId = params.get("taskId")
    new Vue({
        el: '#app',
        data: {
            show: true,
            task: {
                id: taskId,
                title: "",
                content: "",
                createTime: '',
                reply: '',
                status: 0,
                useriinfo: {
                    name: ''
                }
            }
        },
        created() {
            let _this = this;
            axios.get("/task/findById?id=" + taskId)
                .then(function (res) {
                    _this.task = res.data;
                    _this.show = _this.task.status == 1;//初始化状态
                })
        },
        methods: {
            dotask(flag) {
                this.task.status = flag ? 3 : 2;
                let _this = this;
                axios.put("/task/approveSave", this.task)
                    .then(function (res) {
                        if (res.data.success) {
                            mdui.alert("审批成功")
                            _this.show = false
                        }

                    })
            }
        },

    })

</script>


</body>
</html>